import { yunfeng, create, task } from '@zh/common-utils/http'
const http = create(process.env.VUE_APP_API_ZONGHENG_CONNECTOR)
const https = create(process.env.VUE_APP_API_ZONGHENG_YUNFENG)
const schedule = create(process.env.VUE_APP_API_ZONGHENG_SCHEDULE)
// 获取表单信息
export function getCronJobInfo (params) {
  return schedule.get('/manage/get' + `?jobId=${params}`)
}

/** 根据应用id 获取表单列表 */
export const getFromListByApplicationId = function (applicationId) {
  return yunfeng.post(`formDesign/getPartInfoByBelongApplication`, { belongApplication: applicationId })
}

export function appListStatForClass (type, classCode = '', appName = '') {
  return task.post(`/task/TcWorktask/appListStatForClass/${type}?classCode=${classCode}&appName=${appName}`, { type })
}

export function getFormPage (params) {
  return https.post('/form/list', params)
}
export function jobManageAdd (params) {
  return schedule.post('/manage/add', params)
}
export function jobManageUpdate (params) {
  return schedule.post('/manage/update', params)
}
export function jobManageDelete (params) {
  return schedule.post(`/manage/delete?jobIds=${params}`)
}
export function getCronJobInfoPage (params) {
  return schedule.post('/manage/page', params)
}
export function getCronJobInfoGet (params) {
  return schedule.get(`/manage/get?jobId=${params}`)
}
export function jobgroup (id) {
  return schedule.get(`/manage/list/jobgroup`)
}
export function connectorList (id) {
  return http.get(`/list`)
}

export function connectorInfo (id) {
  return http.get(`/info/${id}`)
}

export function saveOrUpdateFormInfo (params) {
  if (params.id) {
    return http.post('/update', params)
  } else {
    return http.post('/save', params)
    // return http.post('/form/save', params)
  }
}
export function connectorPage (params) {
  return http.post('/page', params)
}

export function connectorDelete (params) {
  return http.post('/deleteIds', params)
}
export function connectorDeleteById (params) {
  return http.post('/deleteById', params)
}
export function connectorUpdateState (params) {
  return http.post('/updateState', params)
}

export function connectorinterfacePage (params) {
  return http.post('/connectorinterface/page', params)
}

export function saveOrUpdate (params) {
  if (params.connectorInterfaceVo.id) {
    return http.post('/connectorinterface/interfaceManageUpdate', params)
  } else {
    return http.post('/connectorinterface/addInterfaceAndParamter', params)
  }
}

export function connectorinterfaceDeleteIds (params) {
  return http.post('/connectorinterface/deleteIds', params)
}

export function connectorinterfaceInfo (id) {
  return http.get(`/connectorinterface/info/${id}`)
}

export function buildData (params) {
  return http.post('/connectorinterfaceparameter/buildData', params)
}

export function queryInterfaceAndParamterData (id) {
  return http.get(`/connectorinterface/queryInterfaceAndParamterData/${id}`)
}

export function updateState (params) {
  return http.post('/connectorinterface/update', params)
}

// 接口自定义参数
export function customParameter (params) {
  return http.post('/connectorinterface/customParameter', params)
}
// 执行接口流程
export function execInterface (id) {
  return http.get(`/connectorinterface/execInterface?interfaceId=${id}`)
}